﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Charts
{
    
    public partial class ColChart : Form
    {
      
        public ColChart()
        {
            InitializeComponent();
        }
        //
        private void DrawColChart(String strData, String strInfo, Rect locRect )
        {
            Graphics graph = this.CreateGraphics();
            //rectangle
            SolidBrush brush = new SolidBrush(Color.Blue);
            Rectangle rect = new Rectangle(locRect.x, locRect.y, locRect.w, locRect.h);
            graph.FillRectangle(brush, rect);
		    //string             
            int tempY = locRect.y;
            int tempX = locRect.x;
            locRect.x -= 5;
            locRect.y -= 20;
            DrawString(strData, locRect);            
            locRect.y = tempY;            
            locRect.y += 8 + locRect.h;
            DrawString(strInfo, locRect);
            locRect.x = tempX;
            locRect.y = tempY;      

        }
        //
        private void DrawString(String str, Rect locRect)
        {
            Graphics graph = this.CreateGraphics();
            SolidBrush brush = new SolidBrush(Color.Black);
            //string
            FontStyle fStyle = FontStyle.Regular;
            Font nfStyle = new Font(new FontFamily("Arial"), 12, fStyle);            
            brush.Color = Color.Black;
            graph.DrawString(str,nfStyle, brush, locRect.x, locRect.y);
        }
        //


        private void bttnDrawRectangle_Click(object sender, EventArgs e)
        {
            Rect locRect = new Rect();
            locRect.x = 50; locRect.y = 50; locRect.w = 20; locRect.h = 50;
            for (int i = 0; i <= 31; i++)
            {
                DrawColChart("237", "Test", locRect);
                locRect.x += 30;
            }
            
        }

        
    }
    public class Rect
    {
        public int x;
        public int y;
        public int w;
        public int h;
    }

}
